#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ll long long
#define XH(i,a,b) for(int i = a; i < b; ++i)
#define XXH(i,b,a) for(int i = b; i >= a; --i)
#define Module 998244353
int tmpInt;ll tmpll;string tmpStr;char tmpChar;
vector<int>tmpIntVector;

int main(){
  ll k;
  string s,t;
  cin>>k>>s>>t;
  ll numberCount[10];
  fill(numberCount,numberCount+10,k);
  int a[10],b[10];
  fill(a,a+10,0);
  fill(b,b+10,0);
  XH(i,0,4){
    tmpInt = s[i] - '0';
    numberCount[tmpInt]--;
    a[tmpInt]++;
    tmpInt = t[i] - '0';
    numberCount[tmpInt]--;
    b[tmpInt]++;
  }
  ll sum1 = 0, sum2 = 0;
  XH(i,1,10){
    sum1 += (ll)i * pow(10,a[i]);
    sum2 += (ll)i* pow(10,b[i]);
  }
  ll countNot = 0;
  for(ll i =1;i<=9;++i){
    if(numberCount[i]>0){
      numberCount[i]--;
      ll tsum1 = sum1 + i * pow(10,a[i]+1) - i*pow(10,a[i]);
      for(ll j = 9; j>=1; --j){
        if(numberCount[j]>0){
          ll tsum2 = sum2 + j * pow(10,b[j]+1) - j*pow(10,b[j]);
          if(tsum1<=tsum2){
            if(i == j)countNot += numberCount[i]*(numberCount[i]+1);
            else countNot+=(numberCount[i]+1)*numberCount[j];
          }
        }
      }
      
      numberCount[i]++;
    }
  }
  ll sum = (9*k - 8)*(9*k - 8 -1);
  double ans = (sum - countNot)*1.0/sum;
  cout<<ans<<endl;

  return 0;
}
